// 根据数据渲染，文章列表侧面内容
// 组件递归
<template>
  <ul class="LabelList-content">
    <li v-for="item in list" :key="item.id">
      <span
        class="head"
        :class="{ active: item.isSelect }"
        @click="handleClick(item)"
        >{{ item.name }}</span
      >
      <span class="count" v-if="!item.arcitleCount">{{
        item.articleCount
      }}</span>
      <LabelList
        @select="handleClick"
        :list="item.children"
        v-if="item.children"
      />
    </li>
  </ul>
</template>

<script>
export default {
  name: "LabelList",
  props: {
    list: {
      type: Array,
      required: true,
    },
  },
  methods: {
    handleClick(item) {
      this.$emit("select", item);
    },
  },
};
</script>

<style lang="less" scoped>
@import url("~@/style/var.less");
.LabelList-content {
  font-size: 13px;
  list-style: none;
  padding: 0;
  margin: 0;
  li {
    padding: 5px 0px;
    padding-left: 15px;
    margin: 5px auto;
    color: @dark;
    .head {
      cursor: pointer;
      &.active {
        color: rgb(241, 149, 28);
        font-weight: bold;
      }
      &:hover {
        color: rgb(241, 149, 28);
      }
    }
    .count {
      margin-left: 16px;
      font-size: 10px;
      color: @gray;
    }
  }
}
</style>